package com.zyh.day02.keyvalue

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object CogroupTest {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
      .setAppName("m")
      .setMaster("local[*]")
    val sc = new SparkContext(conf)
    val rdd1: RDD[(Int, String)] = sc.makeRDD(List((1, "手机"), (2, "电脑"), (3, "饰品"),(2,"电脑")))
    val rdd2: RDD[(Int, (Int,String))] = sc.makeRDD(List((1,(101, "iphone13")), (1,(102, "huawei p60")), (2,(103, "mac book pro")), (2,(104, "mate book x"))))
    val rdd3: RDD[(Int, (Iterable[String], Iterable[(Int, String)]))] = rdd1.cogroup(rdd2,4)
    rdd3.foreach(println)
    sc.stop()
  }
}
